<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
        <script type="text/javascript" src="../../inc/ctx.jsp"></script>
        <script type="text/javascript" src="../js/g.js"></script>
        <script type="text/javascript" src="../js/shoptype.js"></script>
        <script type="text/javascript" src="http://cdn.uuola.cn/js/formvalid.js" charset="utf-8"></script>
        <script type="text/javascript" src="http://cdn.uuola.cn/js/address.js" charset="utf-8"></script>
        <link rel="stylesheet" href="../../ked/js/themes/default/default.css" />
        <link rel="stylesheet" href="../../ked/js/plugins/code/prettify.css" />
        <script charset="utf-8" src="../../ked/js/kindeditor-min.js"></script>
        <script charset="utf-8" src="../../ked/js/zh_CN.js"></script>
        <script charset="utf-8" src="../../ked/js/plugins/code/prettify.js"></script>
        <script type="text/javascript" src="../js/channeltype.js"></script>
        <link href="../css/com.css" type="text/css" rel="stylesheet"/>
        <style>
            img.s1{width:100px;border:1px #EFEFEF solid;padding:1px;}
            #panel{width:950px;}
            #panel table{width:940px;}
            span.s1{color:#B1B1B1;}
            #submitBtn{width:150px;height:35px;}
        </style>
    </head>
    <body>

        <div id="panel">
            <form id="addFrm" name="addFrm">
                <table>
                    <tr>
                        <th colspan="3">添加Shop</th>
                    </tr>
                    <tr>
                        <td class="r">所属板块：</td>
                        <td>
                            <script>out_select('channeltype');</script>
                        </td>
                        <td>&nbsp;</td>
                    </tr>
                    <tr>
                        <td class="r">信息类别：</td>
                        <td>
                            <span id="ctp_name_path"> 请选择信息类别 </span>
                            <input type="button" value="选择类别" onclick="selectCatelogs();"/> *
                            <input type="hidden" name="cid" id="cid" value="" />
                            <input type="hidden" name="ctp" id="ctp" value=""  valid="required" errmsg="信息分类不能为空!" />
                        </td>
                        <td><div id="err_ctp"></div></td>
                    </tr>
                    <tr>
                        <td width="180" height="27" class="r">商铺名称：</td>
                        <td width="49%">
                            <input name="shopname" type="text" id="shopname" tabindex="1" size="50" maxlength="32" valid="required" errmsg="事件标题不能为空!" />* 
                    </td>
                        <td width="34%"><div id="err_eventname"><span class="s1">信息标题.60个字符内.勿使用特殊字符.</span></div></td>
                    </tr>
                    <tr>
                        <td class="r">摘要/概要：</td>
                        <td colspan="2"><label for="summary"></label>
                            <textarea name="summary" id="summary" cols="55" rows="6" tabindex="3"></textarea></td>
                    </tr>
                    <tr>
                        <td class="r">发布时间：</td>
                        <td><input type="text" name="_pubtime" maxlength="19" id="_pubtime" tabindex="5">
                        <input type="button" value="" class="calendar"   onclick="cdpn('_pubtime');"/>
                          <input type="hidden" value="" name="pubtime" id="pubtime"/>
                        </td>
                        <td>&nbsp;</td>
                    </tr>
                    <tr>
                      <td class="r">淘宝nick：</td>
                      <td><input name="tbnick" type="text" id="tbnick" tabindex="7" maxlength="32"></td>
                      <td>&nbsp;</td>
                    </tr>
                    <tr>
                      <td class="r">qq：</td>
                      <td><input name="qq" type="text" id="qq" tabindex="7" maxlength="16"></td>
                      <td>&nbsp;</td>
                    </tr>
                    <tr>
                      <td class="r">Email：</td>
                      <td><input name="email" type="text" id="email" tabindex="7" maxlength="64"  valid="required|isEmail" errmsg="邮箱不能为空!|邮箱格式错误!"> * </td>
                      <td><div id="err_email"><span class="s1">请输入商铺管理者邮箱.</span></div></td>
                    </tr>
                    <tr>
                      <td class="r">地区：</td>
                      <td>
<select name="province" id="province" class="s1" style="width:110px;"></select>
<select name="city" id="city" class="s1" style="width:110px;"></select>
<select name="district" id="district" class="s1" style="width:110px;"></select>
<input name="local" type="hidden" id="local" tabindex="7" maxlength="16" /></td>
                      <td>&nbsp;</td>
                    </tr>
                    <tr>
                        <td class="r">shop类型：</td>
                        <td><script>out_shoptype();</script></td>
                        <td>&nbsp;</td>
                    </tr>
                    <tr>
                        <td class="r">是否发布：</td>
                        <td>
                            <label>
                                <input name="pubstate" type="radio" id="pubstate_1" value="1" checked>是</label>
                            <label>
                                <input type="radio" name="pubstate" value="0" id="pubstate_0">否</label>
                        </td>
                        <td>&nbsp;</td>
                    </tr>
                    <tr>
                        <td class="r">是否可评：</td>
                        <td><p>
                                <label>
                                    <input type="radio" name="iscmt" value="1" id="iscmt_1">可评</label>

                                <label>
                                    <input name="iscmt" type="radio" id="iscmt_0" value="0" checked>禁止</label>

                            </p></td>
                        <td>&nbsp;</td>
                    </tr>
                    <tr>
                        <td class="r">信息主图：</td>
                        <td><label for="pic"></label>
                            <input name="pic" type="text" id="pic" size="50">
                            <input type="button" name="uploadBtn" id="uploadBtn" value="上传图片" tabindex="5" onclick="TxBox.upload('pic', '-ms-ss-', '');">
                        </td>
                        <td>&nbsp;</td>
                    </tr>
                    <tr>
                        <td class="r">网店地址：</td>
                        <td><label for="url"></label>
                            <input name="url" type="text" id="url" size="50" maxlength="125">
                        </td>
                        <td>&nbsp;<span class="s1">跳转地址以http://开头</span></td>
                    </tr>
                    <tr>
                        <td class="r">信息内容：</td>
                        <td>&nbsp;</td>
                        <td>&nbsp;</td>
                    </tr>
                    <tr>
                        <td class="c">&nbsp;</td>
                        <td class="c" colspan="2">
                            <textarea name="content" id="content" cols="120" rows="15"></textarea></td>
                    </tr>
                    <tr>
                        <td>&nbsp;</td>
                        <td><input type="hidden" name="channeltype" id="channeltype" value="" /></td>
                        <td>&nbsp;</td>
                    </tr>
                    <tr>
                        <td class="r">&nbsp;</td>
                        <td class="c"><input name="submitBtn" type="button" class="button medium orange" id="submitBtn" tabindex="7" value="添加" onClick="Info.submit();" /></td>
                        <td>&nbsp;</td>
                    </tr>
                    <tr>
                        <td>&nbsp;</td>
                        <td class="c"></td>
                        <td>&nbsp;</td>
                    </tr>
                </table>
            </form>
        </div>



        <script type="text/javascript">
            var frm = ut.e('addFrm');
            initValid(frm);

            // 初始化编辑器
            var contentEditor ; 
            KindEditor.ready(function(K) {
                contentEditor = K.create('#content', {
                    uploadJson : KindUpload.UploadUrl,
                    fileManagerJson : KindUpload.fileMgrUrl,
                    allowFileManager : true,
                    afterCreate : function() {
                        var self = this;
                        self.sync();
                    }
                });
                prettyPrint();
            });
            var Info ={
                submit:function(){
                    var area = [$('#province').val(),$('#city').val(),$('#district').val()].join(' ');
                    $('#local').val(area.indexOf('-')<0?area:'-');
                    contentEditor.sync();
                    if(!convertData()){
                        return;
                    }
                    if(validator(frm)){
                        $.post('../app/hotshop/save.shtm',ut.getFormData('#addFrm'),function(x){
                            if($.trim(x)=='ok'){
                                ut.m('添加成功!');
                                ut.reload('?t='+ut.r()+'&channeltype='+$('#channeltype').val());
                            }else{
                                ut.m('添加失败. '+x);
                            }   
                        });
                    }
                }
            };     

            function convertData(){
                var _pt = $('#_pubtime').val();
                var t1=0;
                if(va.datetime(_pt)){
                    t1 = ut.parseMs(_pt) ;
                }
                if(t1>0)$('#pubtime').val(t1);
                return true;
            };

            function selectCatelogs(){
                  var ct = $('#channeltype').val();
                if(!va.mint(ct)){
                    TxBox.alert('请先选择板块.');
                    return;
                }
                TxBox.winpop(250,350,'类目选择', 'catalogs_select_pop.html?channeltype='+$('#channeltype').val());
            };

            function reloadCatData(cid,ctp){
                $('#cid').val(cid);
                $('#ctp').val(ctp);
                $('#ctp_name_path').text(cid+';'+ctp);
                TxBox.closeWinpop();
            };

            function changeChannelType(){
                $('#ctp_name_path').text('请选择信息类别 ');
                $('#cid').val('');
                $('#ctp').val('');
            };

            jQuery(function(){
                addressInit('province', 'city', 'district');
                $('#channeltype').val('1');
                $('#channeltype').change(function(){
                    changeChannelType();
                    if($('#channeltype').val()!='1'){
                        $('#channeltype').val('1');
                    }
                });
            });
        </script>
    </body>
</html>
